package com.ruoyi.order.controller;

import java.util.Iterator;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.order.api.RemoteCfMyService;
import com.ruoyi.order.api.RemoteCfOrderService;
import com.ruoyi.order.api.RemoteCfServiceSort;
import com.ruoyi.order.api.RemoteEvaluate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.order.domain.CfEvaluateImage;
import com.ruoyi.order.service.ICfEvaluateImageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 评价的照片Controller
 * 
 * @author ruoyi
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/image")
public class CfEvaluateImageController extends BaseController
{
    @Autowired
    private ICfEvaluateImageService cfEvaluateImageService;

    @Autowired
    private RemoteEvaluate evaluate;

    @Autowired
    private RemoteCfMyService myService;

    @Autowired
    private RemoteCfServiceSort remoteCfServiceSort;

    @Autowired
    private RemoteCfOrderService remoteCfOrderService;

    /**
     * 查询评价的照片列表
     */
//    @RequiresPermissions("order:image:list")
    @GetMapping("/list")
    public TableDataInfo list(CfEvaluateImage cfEvaluateImage)
    {
        startPage();
        List<CfEvaluateImage> list = cfEvaluateImageService.selectCfEvaluateImageList(cfEvaluateImage);
        return getDataTable(list);
    }

    /**
     * 导出评价的照片列表
     */
    @RequiresPermissions("order:image:export")
    @Log(title = "评价的照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CfEvaluateImage cfEvaluateImage)
    {
        List<CfEvaluateImage> list = cfEvaluateImageService.selectCfEvaluateImageList(cfEvaluateImage);
        ExcelUtil<CfEvaluateImage> util = new ExcelUtil<CfEvaluateImage>(CfEvaluateImage.class);
        util.exportExcel(response, list, "评价的照片数据");
    }

    /**
     * 获取评价的照片详细信息
     */
//    @RequiresPermissions("order:image:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cfEvaluateImageService.selectCfEvaluateImageById(id));
    }

    /**
     * 新增评价的照片
     */
    @RequiresPermissions("order:image:add")
    @Log(title = "评价的照片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CfEvaluateImage cfEvaluateImage)
    {
        return toAjax(cfEvaluateImageService.insertCfEvaluateImage(cfEvaluateImage));
    }

    /**
     * 修改评价的照片
     */
    @RequiresPermissions("order:image:edit")
    @Log(title = "评价的照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CfEvaluateImage cfEvaluateImage)
    {
        return toAjax(cfEvaluateImageService.updateCfEvaluateImage(cfEvaluateImage));
    }

    /**
     * 删除评价的照片
     */
    @RequiresPermissions("order:image:remove")
    @Log(title = "评价的照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cfEvaluateImageService.deleteCfEvaluateImageByIds(ids));
    }
}
